summon armor_stand ~ ~ ~ {Tags:[tempRA],Invisible:true,Small:true,Marker:true,Invulnerable:true}

item replace entity @n[tag=tempRA,type=armor_stand,distance=..1] weapon.mainhand from entity @s hotbar.8

$data remove entity @n[tag=tempRA,distance=..1,type=armor_stand] HandItems[0].components."minecraft:custom_data".bag[$(index)]

item replace entity @s hotbar.8 from entity @n[tag=tempRA,distance=..1,type=armor_stand] weapon.mainhand

kill @n[tag=tempRA,distance=..1,type=armor_stand]

#自动选择
$execute unless data entity @s Inventory[{Slot:8b}].components."minecraft:custom_data".bag[$(index)] run function dab:system/arrow_bundle/select/previous

#empty
execute store result score #ListSize temp run data get entity @s Inventory[{Slot:8b}].components."minecraft:custom_data".bag
execute unless score #ListSize temp matches 1.. run function dab:system/arrow_bundle/storage/empty
execute unless score #ListSize temp matches 1.. run return run scoreboard players reset #ListSize temp

scoreboard players reset #ListSize temp
playsound item.bundle.remove_one player @a ~ ~ ~ 1.0 1.0

#update
function dab:system/arrow_bundle/storage/update